package com.example.demo.auth.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(
        name = "V_IDM_UNIT"
)
public class UpUnit {
	
    private Long nid;
    private Long npid;
    private String id;
    private String name;
    private String description;
    private String code;
    private String typeId;
    private String isEnabled;
    private String activeFlag;
    /**
     * 创建人
     */
    private String createdBy;
    /**
     * 创建时间
     */
    private Date creationDate;
    /**
     * 修改人
     */
    private String lastUpdatedBy;
    /**
     * 修改时间
     */
    private Date lastUpdateDate;
    private Date deletionDate;
    private String parentUnitId;
    private UpUnitExt upUnitExt;

    @Id
    @Column(name = "NID")
    public Long getNid() {
        return nid;
    }

    public void setNid(Long nid) {
        this.nid = nid;
    }

    @Column(name = "NPID")
    public Long getNpid() {
        return npid;
    }

    public void setNpid(Long npid) {
        this.npid = npid;
    }

    @Column(name = "ID")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Column(name = "NAME")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "DESCRIPTION")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Column(name = "CODE")
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Column(name = "TYPE_ID")
    public String getTypeId() {
        return typeId;
    }

    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }

    @Column(name = "IS_ENABLED")
    public String getIsEnabled() {
        return isEnabled;
    }

    public void setIsEnabled(String isEnabled) {
        this.isEnabled = isEnabled;
    }

    @Column(name = "ACTIVE_FLAG")
    public String getActiveFlag() {
        return activeFlag;
    }

    public void setActiveFlag(String activeFlag) {
        this.activeFlag = activeFlag;
    }

    @Column(
            name = "CREATED_BY"
    )
    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    @Column(
            name = "CREATION_DATE"
    )
    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    @Column(
            name = "LAST_UPDATED_BY"
    )
    public String getLastUpdatedBy() {
        return lastUpdatedBy;
    }

    public void setLastUpdatedBy(String lastUpdatedBy) {
        this.lastUpdatedBy = lastUpdatedBy;
    }

    @Column(
            name = "LAST_UPDATE_DATE"
    )
    public Date getLastUpdateDate() {
        return lastUpdateDate;
    }

    public void setLastUpdateDate(Date lastUpdateDate) {
        this.lastUpdateDate = lastUpdateDate;
    }

    @Column(
            name = "DELETION_DATE"
    )
    public Date getDeletionDate() {
        return deletionDate;
    }

    public void setDeletionDate(Date deletionDate) {
        this.deletionDate = deletionDate;
    }

    @Column(
            name = "PARENT_UNIT_ID"
    )
    public String getParentUnitId() {
        return parentUnitId;
    }

    public void setParentUnitId(String parentUnitId) {
        this.parentUnitId = parentUnitId;
    }

    @OneToOne(cascade=CascadeType.ALL)  //一对一外键关联，使用@OneToOne，并设置了级联操作
    @JoinColumn(name="nid",unique=true)
    public UpUnitExt getUpUnitExt() {
        return upUnitExt;
    }

    public void setUpUnitExt(UpUnitExt upUnitExt) {
        this.upUnitExt = upUnitExt;
    }

    @Transient
    public Long getEntityId() {
        return getNid();
    }
}
